package code.c12;

/**
 * @author thinkpad - 83start
 * @version v1.0
 * @create 2022/11/24 11:31
 * @package code.c12
 * @description 文件说明
 */

public class TestRunnable  {
    public static void main(String[] args) {
        Thread thread1 = new Thread(new MyRunnable());
        thread1.setName("测试线程1");
        thread1.start();

        Thread thread2 = new Thread(new MyRunnable());
        thread2.setName("测试线程2");
        thread2.start();
    }
}

class MyRunnable implements Runnable{
    @Override
    public void run() {
        for (int i = 0; i < 10; i++) {
            try {
                Thread.sleep(500);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(Thread.currentThread().getName());
        }
    }
}
